package com.ktjy.goods.controller;

import com.ktjy.base.R;
import com.ktjy.controller.APIController;
import com.ktjy.goods.service.ProductService;
import com.ktjy.pojo.goods.Product;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品接口
 *
 * @author LILIBO
 * @since 2025-02-18
 */
@Tag(name = "商品接口", description = "商品接口")
@RestController
@RequestMapping("/product")
public class ProductController extends APIController<ProductService, Product> {

    private static final Logger log = LoggerFactory.getLogger(ProductController.class);

    /**
     * 通过ID查询单条商品记录
     *
     * @param id
     * @return R
     */
    @Override
    @Operation(summary = "通过ID查询单条商品记录")
    @GetMapping("/{id}")
    public R getById(@Parameter(description = "商品ID") @PathVariable Long id) {
        log.info("调用商品服务getById()方法 id={}", id);
        try {
            Thread.sleep(6000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return R.success(baseService.getById(id));
    }

}
